package com.indeep.user.controller;


import com.indeep.common.result.JsonResult;
import com.indeep.common.result.StatusCode;
import com.indeep.user.annotation.ControllerLog;
import com.indeep.user.dto.UpdatePrivacySettingDTO;
import com.indeep.user.mapper.po.UpdateBasicUserInfoDTO;
import com.indeep.user.service.AppUserService;
import com.indeep.user.vo.DataExperienceVO;
import com.indeep.user.vo.DataVO;
import com.indeep.user.vo.DataVO;
import com.indeep.user.vo.Privacy1VO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@ControllerLog(name = "用户接口")
@RestController
@RequestMapping("/user")
public class AppUserController {
    
    @Autowired
    private AppUserService appUserService;
    
    @ControllerLog(description = "更新用户关注的分类")
    @RequestMapping("/ydUser/updateTags")
    public JsonResult<String> updateTags() {
        return new JsonResult<>(StatusCode.SUCCESS);
    }
    
    @ControllerLog(description = "获取自己的个人信息")
    @GetMapping("/ydUser/query")
    public JsonResult<DataExperienceVO> getUserInfo() {
        DataExperienceVO vo = appUserService.getUserInfo();
        return new JsonResult<>(StatusCode.SUCCESS, vo);
    }
    
    @ControllerLog(description = "查看主页")
    @RequestMapping("/ydUser/queryHomepage")
    public JsonResult<DataExperienceVO> queryHomepage(@RequestParam("userId") Long userId) {
        DataExperienceVO vo = appUserService.queryHomepage(userId);
        return new JsonResult<>(StatusCode.SUCCESS, vo);
    }

    @ControllerLog(description = "更新个人信息")
    @RequestMapping("/yindi/updateBasic")
    public JsonResult<Object> updateUserBasic(@RequestBody @Validated UpdateBasicUserInfoDTO dto) {
         appUserService.updateBasicInfo(dto);
        return new JsonResult<>(StatusCode.SUCCESS);
    }

    @ControllerLog(description = "更新个人信息 - 注册时")
    @RequestMapping("/ydUser/updateMessage")
    public JsonResult<Object> updateUserBasicFromReg(@RequestBody @Validated UpdateBasicUserInfoDTO dto) {
        appUserService.updateBasicInfo(dto);
        return new JsonResult<>(StatusCode.SUCCESS);
    }

    @ControllerLog(description = "更新设置")
    @RequestMapping("/yindi/updatePrivacy")
    public JsonResult<Object> updatePrivacySetting(@RequestBody UpdatePrivacySettingDTO dto) {
         appUserService.updatePrivacySetting(dto);

        return new JsonResult<>(StatusCode.INTERNAL_SERVER_ERROR);
    }

    @ControllerLog(description = "拉取隐私设置")
    @RequestMapping("/yindi/pushPrivacy")
    public JsonResult<Object> getPrivacy() {
        Privacy1VO privacy = appUserService.getPrivacy();
        if (privacy != null) return new JsonResult<>(StatusCode.SUCCESS, new DataVO(privacy));
        return new JsonResult<>(StatusCode.INTERNAL_SERVER_ERROR);
    }
//
//    @ControllerLog(description = "拉取通知震动状态")
//    @RequestMapping("/yindi/pushMessage")
//    public JsonResult<DataVO> getPrivacy2(HttpServletRequest request) {
//        Privacy2VO privacy = appUserService.getPrivacy2(request);
//        if (privacy != null) return new JsonResult<>(StatusCode.SUCCESS, new DataVO(privacy));
//        return new JsonResult<>(StatusCode.INTERNAL_SERVER_ERROR);
//    }
//
//    @ControllerLog(description = "修改通知震动状态")
//    @RequestMapping("/yindi/updateInform")
//    public JsonResult<Object> updatePrivacy(@RequestBody @Validated PrivacyDTO dto, HttpServletRequest request) {
//        Integer res = appUserService.updatePrivacy(dto, request);
//        if (res == 1) return new JsonResult<>(StatusCode.SUCCESS);
//        return new JsonResult<>(StatusCode.INTERNAL_SERVER_ERROR);
//    }
//
//    @ControllerLog(description = "查询用户头像和用户名")
//    @RequestMapping("/ydUser/queryUserList")
//    public JsonResult<DataVO> queryUserList(@RequestBody UserListDTO dto, HttpServletRequest request) {
//        DataVO vo = appUserService.findUserList(dto);
//        return new JsonResult<>(StatusCode.SUCCESS, vo);
//    }
//
//    @ControllerLog(description = "拉取个性化推荐状态")
//    @RequestMapping("/ydUser/pushIndividuation")
//    public JsonResult<DataVO> queryIndividuation(HttpServletRequest request) {
//        DataVO vo = appUserService.pushIndividuation(request);
//        return new JsonResult<>(StatusCode.SUCCESS, vo);
//    }
//
//    @ControllerLog(description = "修改个性化推荐")
//    @RequestMapping("/ydUser/updateIndividuation")
//    public JsonResult<Object> updateIndividuation(@RequestBody @Validated IndividuationDTO dto, HttpServletRequest request) {
//        Integer res = appUserService.updateIndividuation(dto, request);
//        if (res == 1) return new JsonResult<>(StatusCode.SUCCESS);
//        return new JsonResult<>(StatusCode.INTERNAL_SERVER_ERROR);
//    }
//
//    @ControllerLog(description = "获取用户ID集合")
//    @RequestMapping("/ydUser/getUserIdList")
//    public JsonResult<DataVO> queryIdList(HttpServletRequest request) {
//        List<Long> longs = appUserService.idList(request);
//        return new JsonResult<>(StatusCode.SUCCESS, new DataVO(longs));
//    }
//
//    @ControllerLog(description = "拉取个人主页权限设置")
//    @RequestMapping("/ydUser/pushMyHomePrivacy")
//    public JsonResult<DataVO> queryMyHomePrivacy(HttpServletRequest request) {
//        DataVO vo = appUserService.pushHomePrivacy(request);
//        return new JsonResult<>(StatusCode.SUCCESS, vo);
//    }
//
//    @ControllerLog(description = "修改个人主页权限设置")
//    @RequestMapping("/ydUser/updateMyHomePrivacy")
//    public JsonResult<Object> updateMyHomePrivacy(@RequestBody @Validated MyHomePrivacyDTO dto, HttpServletRequest request) {
//        Integer res = appUserService.updateHomePrivacy(dto, request);
//        if (res == 1) return new JsonResult<>(StatusCode.SUCCESS);
//        return new JsonResult<>(StatusCode.INTERNAL_SERVER_ERROR);
//    }
//
//
    @ControllerLog(description = "获取个人经验值接口")
    @RequestMapping("/ydUser/getExperience")
    public JsonResult<DataVO> queryMyExperience() {
        DataVO vo = appUserService.queryMyExperience();
        return new JsonResult<>(StatusCode.SUCCESS, vo);
    }
    
}
